package tijava.enumerate;

enum CurrencyType {
	/** 阿富汗尼 */
	AFA,
	/** 列克 */
	ALL,
	/** 阿根廷比索 */
	ARP
}

enum Country {
	CHN, USA, JPN
}

public class TypeInCludeEnumField {
	public TypeInCludeEnumField(Country country, CurrencyType currencyType) {
		super();
		this.country = country;
		this.currencyType = currencyType;
		this.desc = "The country " + country + "'s currencyType is "
				+ currencyType;
	}

	public String toString() {
		return this.desc;
	}

	public int hashCode() {
		int result = 17;
		result = 37 * result + this.country.hashCode();
		result = 37 * result + this.currencyType.hashCode();
		result = 37 * result + this.desc.hashCode();
		return result;
	}

	public boolean equals(Object o) {
		if (o == null)
			return false;
		if (this == o)
			return true;
		if (o instanceof TypeInCludeEnumField) {
			TypeInCludeEnumField rhs = (TypeInCludeEnumField) o;
			return ((this.area == rhs.area)
					&& compareField(this.desc, rhs.desc)
					&& compareField(this.country, rhs.country) && compareField(
					this.currencyType, rhs.currencyType));
		}
		return false;
	}

	private static <L, R> boolean compareField(L lhs, R rhs) {
		if (lhs != null && rhs != null)
			return lhs.equals(rhs);
		if (lhs == null && rhs == null)
			return true;
		return false;
	}

	int area;
	String desc;
	Country country;
	CurrencyType currencyType;
}
